package com.yuantu.judiciary.controller;

import com.yuantu.judiciary.common.Response;
import com.yuantu.judiciary.common.ResponseFactory;
import com.yuantu.judiciary.model.vo.DistributorStatisticsVO;
import com.yuantu.judiciary.service.IDistributorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 服务商管理
 *
 * @author syw
 * @since 2023-12-15
 **/
@RestController
@RequestMapping(value = "/distributor")
@Api(tags = "服务商管理")
@RequiredArgsConstructor
public class DistributorController extends BaseController {

    private final IDistributorService distributorService;

    @ApiOperation(value = "服务商统计数据")
    @GetMapping("/get/statistics")
    public Response<List<DistributorStatisticsVO>> getStatistics() {
        Long accountId = getLoginAccount().getAccountId();
        return ResponseFactory.okResponse(distributorService.getStatistics(accountId));
    }

    @ApiOperation(value = "下载服务商统计数据")
    @GetMapping("/download/statistics")
    public Response<Boolean> downloadStatistics(HttpServletResponse response) {
        Long accountId = getLoginAccount().getAccountId();
        return ResponseFactory.okResponse(distributorService.downloadStatistics(response, accountId));
    }

}
